#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=3000+5;
int d[MAXN],v[MAXN],a[MAXN],p[MAXN];
int overspeed[MAXN],used[MAXN][MAXN];

int m,n,L,V,T;

inline void solve(int n,int m,int L,int V){
    int num=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if( v[i]*v[i]+2*a[i]*p[i]<0 ) break;
            if( (v[i]>V && a[i]>=0 )|| (V+v[i])*(V-v[i])<2*a[i]*p[i] ){   //over speed
                overspeed[i]=1;
                ++num;
                used[j][i]=1;
                used[j][0]=1;
            }
        }
    }
    cout<<num<<" ";
    cout<<(int)(num*0.618);//Can not solve it. Give a GUESS!

}


int main(){

    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int i=1;i<=T;++i){
        cin>>n>>m>>L>>V;
        for(int j=1;j<=n;++j){
            cin>>d[j]>>v[j]>>a[j];
        }
        for(int j=1;j<=m;++j){
            cin>>p[j];
        }
        solve(n,m,L,V);
        cout<<"\n";
    }



    return 0;
}
